.class public abstract Lcom/zuiapps/library/download/UpgradeFileDownloadManager;
.super Ljava/lang/Object;
.source "UpgradeFileDownloadManager.java"


# instance fields
.field protected mContext:Landroid/content/Context;

.field protected mZMDownloadManager:Landroid/app/DownloadManager;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 24
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 25
    iput-object p1, p0, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->mContext:Landroid/content/Context;

    .line 26
    const-string v0, "download"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/DownloadManager;

    iput-object v0, p0, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->mZMDownloadManager:Landroid/app/DownloadManager;

    .line 27
    instance-of v0, p1, Landroid/app/Application;

    if-eqz v0, :cond_17

    .line 28
    invoke-direct {p0, p1}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->registerReceiver(Landroid/content/Context;)V

    .line 32
    :goto_16
    return-void

    .line 30
    :cond_17
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->registerReceiver(Landroid/content/Context;)V

    goto :goto_16
.end method

.method private registerReceiver(Landroid/content/Context;)V
    .registers 5
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 72
    new-instance v0, Landroid/content/IntentFilter;

    const-string v2, "android.intent.action.DOWNLOAD_COMPLETE"

    invoke-direct {v0, v2}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    .line 74
    .local v0, "filter":Landroid/content/IntentFilter;
    new-instance v1, Lcom/zuiapps/library/download/UpgradeFileDownloadManager$1;

    invoke-direct {v1, p0}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager$1;-><init>(Lcom/zuiapps/library/download/UpgradeFileDownloadManager;)V

    .line 103
    .local v1, "receiver":Landroid/content/BroadcastReceiver;
    invoke-virtual {p1, v1, v0}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 104
    return-void
.end method


# virtual methods
.method public download(Ljava/lang/String;Ljava/lang/String;)J
    .registers 5
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "displayName"    # Ljava/lang/String;

    .prologue
    .line 35
    invoke-virtual {p0, p1, p2}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->preDowload(Ljava/lang/String;Ljava/lang/String;)V

    .line 36
    invoke-virtual {p0, p1, p2}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->execDownload(Ljava/lang/String;Ljava/lang/String;)J

    move-result-wide v0

    return-wide v0
.end method

.method protected execDownload(Ljava/lang/String;Ljava/lang/String;)J
    .registers 9
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "displayName"    # Ljava/lang/String;
    .annotation build Landroid/annotation/TargetApi;
        value = 0xb
    .end annotation

    .prologue
    .line 50
    :try_start_0
    invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    .line 52
    .local v1, "resource":Landroid/net/Uri;
    new-instance v0, Landroid/app/DownloadManager$Request;

    invoke-direct {v0, v1}, Landroid/app/DownloadManager$Request;-><init>(Landroid/net/Uri;)V

    .line 53
    .local v0, "request":Landroid/app/DownloadManager$Request;
    const/4 v3, 0x1

    invoke-virtual {v0, v3}, Landroid/app/DownloadManager$Request;->setVisibleInDownloadsUi(Z)Landroid/app/DownloadManager$Request;

    .line 54
    invoke-virtual {v0, p2}, Landroid/app/DownloadManager$Request;->setTitle(Ljava/lang/CharSequence;)Landroid/app/DownloadManager$Request;

    .line 55
    sget v3, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v4, 0xb

    if-lt v3, v4, :cond_1a

    .line 56
    const/4 v3, 0x1

    invoke-virtual {v0, v3}, Landroid/app/DownloadManager$Request;->setNotificationVisibility(I)Landroid/app/DownloadManager$Request;

    .line 58
    :cond_1a
    const/4 v3, 0x3

    invoke-virtual {v0, v3}, Landroid/app/DownloadManager$Request;->setAllowedNetworkTypes(I)Landroid/app/DownloadManager$Request;

    .line 59
    invoke-virtual {p0}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->getBaseDownloadPath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {p0, p1}, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->getFileName(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v0, v3, v4}, Landroid/app/DownloadManager$Request;->setDestinationInExternalPublicDir(Ljava/lang/String;Ljava/lang/String;)Landroid/app/DownloadManager$Request;

    .line 60
    const-string v3, "application/vnd.android.package-archive"

    invoke-virtual {v0, v3}, Landroid/app/DownloadManager$Request;->setMimeType(Ljava/lang/String;)Landroid/app/DownloadManager$Request;

    .line 61
    invoke-virtual {v0, p2}, Landroid/app/DownloadManager$Request;->setDescription(Ljava/lang/CharSequence;)Landroid/app/DownloadManager$Request;

    .line 63
    iget-object v3, p0, Lcom/zuiapps/library/download/UpgradeFileDownloadManager;->mZMDownloadManager:Landroid/app/DownloadManager;

    invoke-virtual {v3, v0}, Landroid/app/DownloadManager;->enqueue(Landroid/app/DownloadManager$Request;)J
    :try_end_36
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_36} :catch_38

    move-result-wide v4

    .line 67
    .end local v0    # "request":Landroid/app/DownloadManager$Request;
    .end local v1    # "resource":Landroid/net/Uri;
    :goto_37
    return-wide v4

    .line 64
    :catch_38
    move-exception v2

    .line 65
    .local v2, "t":Ljava/lang/Throwable;
    invoke-virtual {v2}, Ljava/lang/Throwable;->printStackTrace()V

    .line 67
    const-wide/16 v4, -0x64

    goto :goto_37
.end method

.method public abstract getBaseDownloadPath()Ljava/lang/String;
.end method

.method public abstract getFileName(Ljava/lang/String;)Ljava/lang/String;
.end method

.method protected installApk(Landroid/content/Context;Ljava/io/File;)V
    .registers 7
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "file"    # Ljava/io/File;

    .prologue
    .line 108
    :try_start_0
    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    .line 109
    .local v0, "intent":Landroid/content/Intent;
    const-string v2, "android.intent.action.VIEW"

    invoke-virtual {v0, v2}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;

    .line 110
    const-string v2, "android.intent.category.DEFAULT"

    invoke-virtual {v0, v2}, Landroid/content/Intent;->addCategory(Ljava/lang/String;)Landroid/content/Intent;

    .line 111
    const-string v2, "application/vnd.android.package-archive"

    invoke-virtual {v0, v2}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

    .line 112
    invoke-static {p2}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;

    move-result-object v2

    invoke-virtual {v0, v2}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 113
    instance-of v2, p1, Landroid/app/Application;

    if-eqz v2, :cond_24

    .line 114
    const/high16 v2, 0x10000000

    invoke-virtual {v0, v2}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;

    .line 116
    :cond_24
    invoke-static {p2}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;

    move-result-object v2

    const-string v3, "application/vnd.android.package-archive"

    invoke-virtual {v0, v2, v3}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 117
    invoke-virtual {p1, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_30
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_30} :catch_31

    .line 121
    .end local v0    # "intent":Landroid/content/Intent;
    :goto_30
    return-void

    .line 118
    :catch_31
    move-exception v1

    .line 119
    .local v1, "t":Ljava/lang/Throwable;
    invoke-virtual {v1}, Ljava/lang/Throwable;->printStackTrace()V

    goto :goto_30
.end method

.method public abstract postDowload(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
.end method

.method public abstract preDowload(Ljava/lang/String;Ljava/lang/String;)V
.end method
